<style type="text/css">
	fieldset{ margin: 20px 0; }
	legend{ font-size: 14px; margin:5px; padding:5px;}
	.col-sm-2{width:100px; font-weight:normal;}
</style>
<?php $this->renderPartial('/admin/menu/content');?>
<h4><?php echo Yii::t('helpdesk','Documents'); ?></h4><br>
<?php
foreach(Yii::app()->user->getFlashes() as $key => $message){
	echo '<div class="'.$key.'"><p>'.$message."</p></div>\n";
}
?>
<a href="/admin/documents/form"><i title="add new" class="glyphicon glyphicon-plus"></i> <?php echo Yii::t('helpdesk','Add new'); ?></a>
<form role="form" method="post">
<fieldset>
	<legend><?php echo Yii::t('helpdesk','Filter'); ?></legend>
    <div class="form-group">
        <label for="inputEmail" class="col-sm-2"><?php echo Yii::t('helpdesk','Folder'); ?></label>
        <select id="folder" name="folder" onChange="window.location='/admin/documents/?folder='+this.value">
			<option value="">- <?php echo Yii::t('helpdesk','All'); ?> -</option>
			<?php foreach($arrFolders as $R): ?>
            <option value="<?php echo $R['category_id']; ?>" <?php if( isset($arrFilter['folder']) && $R['category_id'] == $arrFilter['folder']):?>selected=""<?php endif; ?>> <?php for($i=0; $i<$R['category_level']; $i++): echo '&nbsp;&nbsp;&nbsp;&nbsp;'; endfor;?>  <?php echo $R['category_name']; ?></option>
            <?php endforeach; ?>
        </select>
    </div>
</fieldset>
</form>
<table style="width: 100%;" class="table table-striped table-bordered table-nonfluid">
<tbody>
	<tr>
        <th><?php echo Yii::t('helpdesk','Documents'); ?></th>
        <th width="80px"><?php echo Yii::t('helpdesk','Actions'); ?></th>
	</tr>
    <?php if(!empty($arrDocuments)): ?>
    <?php foreach($arrDocuments as $R): ?>
	<tr>
    	<td><a href="/admin/documents/form/?id=<?php echo $R['post_id']; ?>"><?php echo $R['post_title']; ?></a></td>
        <td>
        	<a href="/admin/documents/form/?id=<?php echo $R['post_id']; ?>"><i title="<?php echo Yii::t('helpdesk','Edit'); ?>" class="glyphicon glyphicon-edit"></i></a>
            &nbsp;
            <a onclick="return confirm('<?php echo Yii::t('helpdesk','Are you sure you want to delete?'); ?>')" href="/admin/documents/?id=<?php echo $R['post_id']; ?>&act=delete"><i title="<?php echo Yii::t('helpdesk','Delete'); ?>" class="glyphicon glyphicon-remove-circle"></i></a>
        </td>
    </tr>
    <?php endforeach; ?>
    <?php else: ?>
    <tr>
    	<td colspan="2"><?php echo Yii::t('helpdesk','No data found'); ?></td>
    </tr>
    <?php endif; ?>   
</tbody></table>

<?php $this->widget('Pagination', array(
	'pages' => $objPages,
)) ?>